<?
/*
 * Copyright 2004-2005 Sigve Indregard.
 *
 * This file is part of Laivsys.
 *
 * Laivsys is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * Laivsys is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Laivsys; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

/*
 * $Id: laivid.php 6 2005-07-11 23:14:47Z say $
 */
 
//set the session laivID - if requested
if (isset($_REQUEST['laivID'])) {
	$id = $_REQUEST['laivID'];
	
	if (!is_numeric($id)) 
		die("Erronous laivID");

	$sql = "SELECT * FROM laiv WHERE ID=$id AND Offentlig=1";
	$laivs = mysql_query($sql);

	if (mysql_num_rows($laivs) == 1) {
		$_SESSION['laivID'] = $id;
		session_unregister('AuthStatus');
	} else {
		die("Erronous laivID");
	}
} elseif (!isset($_SESSION['laivID'])) {
	die("No laivID");
}

function getLaiv() {
	$sql = "SELECT *, NOW() > Pamelding_start AS pam_Startet, NOW() > Pamelding_slutt AS pam_Sluttet  FROM Laiv WHERE ID=".$_SESSION['laivID'];
	$retur = mysql_query($sql);

	if (mysql_num_rows($retur) == 1) {
		$data = mysql_fetch_assoc($retur);
		return $data;
	} else {
		return null;
	}
}
?>
